﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Serialization;

namespace TienTeTuong
{
    public partial class AjaxSearchProductAdd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string keyWord = Request.Params["Key"] ?? "";
            ProductDetailBUS proBus = new ProductDetailBUS();
            List<ProductDetailDTO> lstPro = proBus.searchProductDetailByName(keyWord);
            var serializer = new JavaScriptSerializer();
            string json = serializer.Serialize(new
            {
                aaData = lstPro.Select(p => new object[] {
                    p.ProID,
                    p.Name,
                    p.Price
                })
            });
            Response.Write(json);
        }
    }
}